/*
 * @Description: 
 * @Autor: wanghuan
 * @Date: 2021-11-29 15:20:39
 * @LastEditors: wanghuan
 * @LastEditTime: 2021-11-29 15:59:22
 */

const $_token = {
    // 请求头key
    headerKey:"token"
    // 缓存key
    ,storageKey:"token"
    // token val
    ,token:""
    // 挂在缓存指向
    ,storage: localStorage
    // 取token
    ,getToken(){
        const { storageKey , storage } = tokenConfig;
        return storage[storageKey];
    }
    // 设置 token
    ,setToken( token ){
        const { storageKey , storage  } = tokenConfig;
        if( token ){
            storage[storageKey] = token;
        }else{
            throw Error("param token must be required");
        }
    }
    // 清除 token
    ,clearToken(){
        const { storageKey , storage } = tokenConfig;
        delete storage[storageKey];
    }
    
};
 module.exports = {
    $_token
 }